﻿using Application.AppService.EIAppService;
using Application.AppService.ERAppService;
using Application.Service;
using AutoMapper;
using Domain;
using Domain.Entity;
using Hangfire;
using Microsoft.AspNetCore.Mvc;

namespace UI.Controllers.RecruitmentManagement_招聘管理_.Employment_management_录用管理_
{
	public class ERApprovalController : Controller
	{
		private readonly IMapper mapper;
		private readonly IERAppService eRAppService;
		private readonly IEIAppService eIAppService;
        private readonly IEmailService emailService;

        public ERApprovalController(IMapper mapper, IERAppService eRAppService, IEIAppService eIAppService,IEmailService emailService)
		{
			this.mapper = mapper;
			this.eRAppService = eRAppService;
			this.eIAppService = eIAppService;
            this.emailService = emailService;
        }
		public IActionResult Index()
		{
			return View();
		}
		public IActionResult Index1()
		{
			return View();
		}
		[HttpPost("FYERApproval")]
		public IActionResult FYERApproval(int page, int pageSize)
		{

			ERFenYE erFenYE = eRAppService.DateERSAsync(page, pageSize, 4);
			return Json(erFenYE);
		}
		[HttpPost("UpdateERApproval")]
		public async Task<IActionResult> UpdateERApproval(ER er)
		{
			bool rs = await eRAppService.UpdateERApprovalAsync(er);
			return Json(rs);
		}
        [HttpPost("SendEmail")]
        public IActionResult SendEmail(string email)
		{
            BackgroundJob.Enqueue(() => emailService.SendEmail(email));
            return Json("Email发送成功!");
        }
    }
}
